package com.monster.service;

import com.monster.dao.AlbumDao;
import com.monster.dao.AlbumDaoImpl;
import com.monster.dao.PlaylistDao;
import com.monster.dao.PlaylistDaoImpl;
import com.monster.dao.SingerDao;
import com.monster.dao.SingerDaoImpl;
import com.monster.pojo.Album;
import com.monster.pojo.Playlist;
import com.monster.pojo.Singer;
import com.monster.pojo.Song;
import com.monster.pojo.Tag;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 歌手，专辑，歌单页面查询
 * @author lym
 */
public class ListServiceImpl implements AlbumService,PlaylistService,SingerService{
    private AlbumDao albumDao = new AlbumDaoImpl();
    private PlaylistDao playlistDao = new PlaylistDaoImpl();
    private SingerDao singerDao = new SingerDaoImpl();

    //获取歌单总数量
    @Override
    public int getTotalCount(Tag tag,String orderType){
        return playlistDao.getTotalCount(tag,orderType);
    }

    /**
     * 用户点击导航栏，输出查询全部，按照热度降序排列
     * @param page
     * @return Arraylist<Album> albums
     * @author lym
     */
    @Override
    public ArrayList<Album> getAllAlbums(int page) {
        return albumDao.getAllAlbums(page);
    }

    /**
     * 用户筛选组合，按照用户选择排序排列
     * @param language,genre,ordertype,page
     * @return Arraylist<Album> albums
     * @author lym
     */

    @Override
    public ArrayList<Album> getAllAlbums(String language, String genre, String orderType,int page) {
        return albumDao.findAlbumbyAlbumLanguageGenre(language,genre,orderType,page);
    }

    /**
     * 用户点击导航栏分类歌单，调用查询全部，按热度降序排列
     * @param page
     * @return 歌单集合
     * size  页面显示数量
     */

    @Override
    public List<Playlist> playlists(int page,int size) {
        return playlistDao.findAll(page,size);
    }

    /**
     * 根据用户选择的tag查询歌单
     * @param tag,page
     * @@return 歌单集合
     * @author lym
     */

    @Override
    public List<Playlist> selectPlaylistByTag(Tag tag,String orderType, int page,int size) {
        return playlistDao.selectPlaylistByTag(tag,orderType,page,size);
    }


    /**
     * 点击歌手，查询全部，按降序排列，每页60个
     * @param page
     * @return singer集合
     */

    @Override
    public ArrayList<Singer> getAllSingers(int page) {
        return singerDao.getAllSingers(page);
    }

    /**
     * 根据用户不同的筛选组合查询，按照热度降序排列，每页60
     * @param firstLetter,area,genre,sex,page
     * @return singer集合
     */

    @Override
    public ArrayList<Singer> getSingersByOption(String firstLetter, String area, String sex, String genre,int page) {
        return singerDao.getSingersByOption(firstLetter,area,sex,genre,page);
    }

    @Override
    public ArrayList<Singer> getSingersSongsByArea(String area, int page) {
        return singerDao.getSingersSongsByArea(area,page);
    }

    @Override
    public ArrayList<Singer> getSingersAlbumsByArea(String area, int page) {
        return singerDao.getSingersAlbumsByArea(area,page);
    }

    @Override
    public ArrayList<Album> findAlbumbyAlbumname(String name) {
        return albumDao.findAlbumbyAlbumname(name);
    }

    @Override
    public List<Playlist> selectPlaylist(String name) {
        return playlistDao.selectPlaylist(name);
    }
    /**
     * 通过标签分类查询歌单
     */
    @Override
    public List<Playlist> findPlaylistByTagType(Tag tag,int page){
        return playlistDao.selectPlaylistByTagType(tag,page);
    }

    @Override
    public Singer getSingersBySingerId(Long singerId) {
        return singerDao.getSingersBySingerId(singerId);
    }

    @Override
    public Singer songsAlbumsAmount(Long singerId) {
        return singerDao.songsAlbumsAmount(singerId);
    }

    @Override
    public ArrayList<Song> getSongsBySingerId(Long singerId) {
        return singerDao.getSongsBySingerId(singerId);
    }

    @Override
    public List<Album> selectAlbumBySingerId(Long singerId) {
        return singerDao.selectAlbumBySingerId(singerId);
    }

    @Override
    public ArrayList<Singer> getSingersByFuzzy(String letter) {
        return singerDao.getSingersByFuzzy(letter);
    }

}
